#include "dart_api/dart_api.h"
#include "dart_api/dart_native_api.h"
#include "dart_api/dart_api_dl.h"
#include "trtc_c_api/trtc_cloud.h"
#include "trtc_c_api/trtc_cloud_type.h"
#include "trtc_c_api/trtc_cloud_callback.h"
#include "trtc_c_api/tx_audio_effect_manager.h"
#include "trtc_c_api/tx_device_manager.h"

#if _WIN32
#define FFI_PLUGIN_EXPORT __declspec(dllexport)
#else
#define FFI_PLUGIN_EXPORT
#endif

//#define DART_API extern "C" __attribute__((visibility("default"))) __attribute__((used))

#ifdef __cplusplus
#define DART_API extern "C"
extern "C" {
}
#else
#define DART_API
#endif

typedef enum {
    _log = 0,
    _video_custom_process = 1,
    _local_video_render = 2,
    _remote_video_render = 3,
    _audio_frame = 4,
    _music_preload = 5,
    _music_play = 6,
    _device_change = 7
} trtc_cloud_callback_type_e;


DART_API FFI_PLUGIN_EXPORT intptr_t InitDartApiDL_TRTC(void* data);
DART_API FFI_PLUGIN_EXPORT void RegisterTRTCListener(Dart_Port sendPort, trtc_cloud trtc_cloud_ptr);
DART_API FFI_PLUGIN_EXPORT void UnRegisterTRTCListener(trtc_cloud trtc_cloud_ptr);

DART_API FFI_PLUGIN_EXPORT int setCallback(Dart_Port sendPort,
                                           trtc_cloud trtc_cloud_ptr,
                                           int callback_type,
                                           char* callback_param,
                                           bool enable);

DART_API FFI_PLUGIN_EXPORT int callApi(trtc_cloud instance);

DART_API FFI_PLUGIN_EXPORT void RegisterVideoFrameListener(Dart_Port sendPort, trtc_cloud trtc_cloud_ptr);
DART_API FFI_PLUGIN_EXPORT void UnRegisterVideoFrameListener(trtc_cloud trtc_cloud_ptr);

DART_API FFI_PLUGIN_EXPORT void RegisterVideoRenderListener(Dart_Port sendPort, trtc_cloud trtc_cloud_ptr);
DART_API FFI_PLUGIN_EXPORT void UnRegisterVideoRenderListener(trtc_cloud trtc_cloud_ptr);

DART_API FFI_PLUGIN_EXPORT int trtc_cloud_set_network_qos_param_backup(trtc_cloud instance, int preference, int controlMode);
DART_API FFI_PLUGIN_EXPORT int trtc_cloud_enable_audio_volume_evaluation_backup(trtc_cloud instance,
                                                                                int enable,
                                                                                int interval,
                                                                                int enable_vad_detection,
                                                                                int enable_pitch_calculation,
                                                                                int enable_spectrum_calculation);

DART_API FFI_PLUGIN_EXPORT int start_local_preview_texture(trtc_cloud instance, bool front_camera, int64_t texture_id);
DART_API FFI_PLUGIN_EXPORT int start_remote_view_texture(trtc_cloud instance, const char* user_id, int stream_type, int64_t texture_id);